package data.map;

public class TerrainMap {

	private int size;

	private int[][] map;

	public TerrainMap(int size) {
		map = new int[size][size];
		this.size = size;
	}

	public int getTerrainAt(int x, int y) {
		return map[x][y];
	}

	public void setTerrainAt(int x, int y, int terrain) {
		map[x][y] = terrain;
	}
	
	public int getSize(){
		return this.size;
	}
	
	public int[][] getIdentity(){
		return map;
	}
	
	public void rerollMap(){
		for(int i = 0; i < size; i++){
			for(int j = 0; j < size; j++){
				map[i][j] = 0;
			}
		}
	}
	
	public String getMapAsString(){
		String str = "";
		for(int i = 0; i < size; i++){
			for(int j = 0; j < size; j++){
				if(!str.equals("")) str = str + "-";
				str = str + map[i][j];
			}
		}
		return str;
	}

	public void buildFromString(String str) {
		String[] split = str.split("-");
		int j = 0;
		for(int i = 0; i < split.length; i++){
			map[i/32][i%32] = Integer.valueOf(split[i]);
		}
		
	}
}
